package com.aop;

import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
@Configuration
public class WebConfig implements WebMvcConfigurer {
    private final TrackingInterceptor trackingInterceptor;

    public WebConfig(TrackingInterceptor trackingInterceptor) {
        this.trackingInterceptor = trackingInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(trackingInterceptor)
                .addPathPatterns("/**"); // 拦截所有请求
    }
}

